/** Create_entry_exit_flags.sas
**** Construct entry and exit dummies for all 2002,2007 CMF plants and save the dataset. ;
***/


/* OPTIONS OBS=100  NOREPLACE  ; */

%include "ASMimplibs.sas";


 data bcd02 (keep=survu_id te02);
  set cmf.cmf2002;te02=te;
 run; 
 data bcd07 (keep=survu_id te07);
  set cmf.cmf2007;te07=te;
 run; 

 data fhs.bcd0207;
  merge bcd02 bcd07;
  by survu_id;
  if te02>0 and te07>0 then cont0207=1; else cont0207=0;
  if (te02=0 or te02=.) and te07>0 then ent07 = 1; else ent07=0;
  if te02>0 and (te07=0 or te07=.) then exit02 = 1; else exit02=0;
 run;

proc datasets library=fhs;
 modify bcd0207;
  label ent07 = 'Entry in 2007';
  label exit02 = 'Exit in 2002';
  label cont0207 = 'Continuer, 2002-2007';
run;


proc sort data=fhs.bcd0207; by survu_id; run;
